using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class ClickablePart : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
    public bool isSuspect;

    public GameObject DialogGroup;

    //Detect if a click occurs
    public void OnPointerClick(PointerEventData pointerEventData)
    {
        //Output to console the clicked GameObject's name and the following message. You can replace this with your own actions for when clicking the GameObject.
        Debug.Log(name + " Game Object Clicked!");

        if (isSuspect)
        {
            //每一个有问题可以盘问的部分，都会跳出一组对话。
            NPCManager.instance.GenerateNPCDialogBox(DialogGroup);
        }
        else
        {
            //没有问题的话，则在屏幕上方跳出提示框，提示没问题。
            UIManager.instance.MessageBox.SetActive(true);
            Invoke("CloseMessageBox",1.2f);
        }
        NPCManager.instance.AskModeSwitch();
    }

    public void OnPointerEnter(PointerEventData pointerEventData)
    {
        Cursor.SetCursor(NPCManager.instance.cursorTextureMagnifier, Vector2.zero, CursorMode.ForceSoftware);
    }
    
    public void OnPointerExit(PointerEventData pointerEventData)
    {
        Cursor.SetCursor(NPCManager.instance.cursorTextureNormal, Vector2.zero, CursorMode.ForceSoftware);
    }

    public void CloseMessageBox()
    {
        UIManager.instance.MessageBox.SetActive(false);
    }
}
